package org.lalib.controller.service;

import java.util.Date;
import java.util.List;

import org.lalib.acquire.IControllerService;
import org.lalib.entity.object.ETable;
import org.lalib.mediator.MTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Scope("request")
@Service("cTableService")
public class CTableService implements IControllerService {

	private static final long serialVersionUID = 1L;

	@Autowired
	private MTable mTable;

	public void save(String name, Date since, Date till) {
		ETable table = new ETable();
		table.setName(name);
		table.setSince(since);
		table.setTill(till);
		mTable.insert(table);
	}
	
	public void delete(ETable table){
		mTable.remove(table);
	}

	public List<ETable> getAllTables() {
		return mTable.getAllTables();
	}

	public void update(ETable table) {
		mTable.update(table);
	}

	public void setmTable(MTable mTable) {
		this.mTable = mTable;
	}

	public List<ETable> getTableListForGivenName(String name) {
		return mTable.getTableListForGivenName(name);
	}

	public ETable getTableById(Long id) {
		return mTable.getEntityById(id);
	}
}